<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    ul {
      list-style: none;
      margin: 0;
      padding: 0;
    }

    li {
      display: flex;
      align-items: center;
    }

    .s {
      color: purple;
    }
    h3 {
      margin: 0;
      font-weight: normal;
    }


  </style>
</head>
<body>
  <div id="app">
    <ul>
      <li v-for="topic in topics">
        <img width="30" height="30" :title="topic.author.loginname" :src="topic.author.avatar_url" alt="">
        <div>
          <span class="s">{{topic.reply_count}}</span>/<span>{{topic.visit_count}}</span> 
        </div>
        <h3>{{topic.title}}</h3>
      </li>
    </ul>

  </div>
  <script src="./vue.js"></script>
  <script src="./axios.min.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        topics: []
      },
      methods: {
        /* getTopics () {
          axios.get('https://cnodejs.org/api/v1/topics').then(res => {
            // res.data.data 就是我们要获取的文章数组
            this.topics = res.data.data
          })
        } */
        async getTopics () {
          try {
            const res = await axios.get('https://cnodejs.org/api/v1/topics')
            this.topics = res.data.data
          } catch (error) {
            console.log(error)
          }
        }
      },
      created () {
        this.getTopics()
      }
    })
  </script>
  
</body>
</html>